#ifndef ESP01S_H
#define ESP01S_H
#include "bsp_system.h"

#define BUILDING_INFO "南5" // 楼号 直接区＋数字即可
#define ROOM_ID_INFO 704    // 房间号
#define LIMIT_INFO 1        // 查询条数

#define W_ENABLE 1
#define W_DISABLE 0
#define W_OK 1
#define W_ERROR 0
typedef struct
{
    uint8_t init_flag;
    uint8_t start_flag;
    uint8_t receiveDataFlag;
    uint16_t error_code;
} ML307R_TypeDef;

typedef struct
{
    float remain;         // 剩余电量
    char update_time[20]; // 更新时间
    float usage;          // 用电量
    char time[20];        // 用电时间
} ML307R_Data;

typedef enum
{
    SOUTH_1 = 0,
    SOUTH_2,
    SOUTH_3,
    SOUTH_4,
    SOUTH_5,
    SOUTH_6,
    SOUTH_7,
    SOUTH_8,
    CENTER_1A,
    CENTER_1B,
    CENTER_1C,
    CENTER_1D,
    EAST_20,
    EAST_21,
    EAST_22,
    EAST_23,
} BUILDING_MAP_TYPE;

float ml307r_get_remain(void);
float ml307r_get_usage(void);
char *ml307r_get_update_time(void);
char *ml307r_get_time(void);

char *get_building_map_index(uint8_t index);
char *get_building_map_remain_index(uint8_t index); // 获取楼号去掉第一个中文字符
char *get_building_map(void);                       // 获取楼号
void set_building_map_num(uint8_t index);
uint16_t get_building_room_num(void);
uint8_t get_building_map_num(void);
void set_building_floor_num(uint8_t floor);
void set_building_room_num(uint8_t room);

int ml307r_init(void);
uint8_t ml307r_get_init_flag(void);
uint8_t ml307r_get_start_flag(void);
void set_ml307r_start_flag(uint8_t flag);
void ml307r_get_electricity(void);
void ml307r_get_change_electricity(void);
#endif
